﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace NAccounting.QueryObjects
{
    public class ProjectQueryObject : QueryObject<Project>
    {
        public ProjectQueryObject(NAccountEntities context) 
            : base(context) 
        {}

        public override PagedResult<Project> Get(int pageIndex, int rows)
        {
            var result = new PagedResult<Project>();
            result.Total = Context.Projects
                                  .Count();

            result.List = Context.Projects
                                 .OrderBy(x => x.Name)
                                 .Skip(pageIndex * rows)
                                 .Take(rows).ToArray();
            return result;
        }
    }
}